package com.admin.service.impl;

import com.admin.entity.Room;
import com.admin.dao.RoomMapper;
import com.admin.service.RoomService;
import com.admin.vo.query.RoomQueryVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 宿舍表 服务实现类
 * </p>
 *
 * @author szy
 * @since 2023-03-14
 */
@Service
@Transactional
public class RoomServiceImpl extends ServiceImpl<RoomMapper, Room> implements RoomService {

    @Override
    public IPage<Room> getRoomyByPage(IPage<Room> page, RoomQueryVo roomQueryVo) {
        QueryWrapper<Room> queryWrapper = new QueryWrapper<Room>();
        //楼幢
        queryWrapper.like(!ObjectUtils.isEmpty(roomQueryVo.getDormitoryId()),
                "dormitory_id",roomQueryVo.getDormitoryId());
        //门牌号
        queryWrapper.like(!ObjectUtils.isEmpty(roomQueryVo.getTablet()),
                "tablet",roomQueryVo.getTablet());
        return baseMapper.selectPage(page,queryWrapper);
    }
}
